package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

/**
 *
 */
public class CoffeeMakerTest extends TestCase {
	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1;
	private Recipe r2;
	private Recipe r3;
	private Recipe r4;


	public void setUp() {
		cm = new CoffeeMaker();
		i = cm.checkInventory();
		
		r1 = new Recipe();
		r1.setName("Recipe 1");
		r1.setPrice(1);
		r1.setAmtCoffee(2);
		r1.setAmtMilk(1);
		r1.setAmtSugar(2);
		r1.setAmtChocolate(1);
		
		r2 = new Recipe();
		r2.setName("Recipe 2");
		r2.setPrice(1);
		r2.setAmtCoffee(2);
		r2.setAmtMilk(1);
		r2.setAmtSugar(2);
		r2.setAmtChocolate(1);
		
		r3 = new Recipe();
		r3.setName("Recipe 3");
		r3.setPrice(1);
		r3.setAmtCoffee(2);
		r3.setAmtMilk(1);
		r3.setAmtSugar(2);
		r3.setAmtChocolate(1);
		
		r4 = new Recipe();
		r4.setName("Recipe 4");
		r4.setPrice(1);
		r4.setAmtCoffee(2);
		r4.setAmtMilk(1);
		r4.setAmtSugar(2);
		r4.setAmtChocolate(1);
	}
//Testing all valid Inputs
	
	public void testAddRecipe1() {
		assertTrue(cm.addRecipe(r1));
	}

	//Testing adding a Duplicate recipe
	public void testDeleteRecipe1() {
		cm.addRecipe(r1);
		assertTrue(cm.deleteRecipe(r1));
	}
	
	// Testing adding too many recipes
	public void testAddRecipe3() {
		
	
	cm.addRecipe(r1);
	cm.addRecipe(r2);
	cm.addRecipe(r3);
	cm.addRecipe(r4);
	
	Recipe r5 = new Recipe();
	r5.setName("Recipe 5");
	r5.setPrice(1);
	r5.setAmtCoffee(2);
	r5.setAmtMilk(1);
	r5.setAmtSugar(2);
	r5.setAmtChocolate(1);
	
	assertFalse(cm.addRecipe(r5));

	}
	//Testing editing a recipe if already 4
		public void testEditRecipe2() {
			cm.addRecipe(r1);
			cm.addRecipe(r2);
			cm.addRecipe(r3);
			cm.addRecipe(r4);
			Recipe newRecipe = new Recipe();
			newRecipe = r1;
			assertFalse(cm.editRecipe(r1, newRecipe));
		}
		//Testing deleting a null recipe
		
		public void testDeleteRecipe2() {
			assertFalse(cm.deleteRecipe(null));
		}
		public void testAddInventory1() {
	    	assertFalse(cm.addInventory(1, 1, 1, 1));
	    }
		public void testAddInventory2() {
	    	assertTrue(cm.addInventory(1, 1, -1, 1));
	    }

		public void testMakeCoffee1() {
	    	cm.addRecipe(r1);
	    	
	    	assertEquals(0, cm.makeCoffee(r1, 0) );
		}
		// Testing Not enough ingredients
    public void testMakeCoffee3() {
    	cm.addRecipe(r4);
    	
    	assertEquals(1, cm.makeCoffee(r3, 1) );
    } 
		
		//Testing Wrong amount of money
		 public void testMakeCoffee2() {
		    	cm.addRecipe(r1);
		    	
		    	assertEquals(0, cm.makeCoffee(r1, 0) );
		 }
		 
		 public void testGetRecipeForName1() {
				cm.addRecipe(r1);
				assertEquals(r1, cm.getRecipeForName("Recipe 1"));
			}

	public void testAddRecipe2() {
		cm.addRecipe(r1);
		assertFalse(cm.addRecipe(r1));
	}

	public void testEditRecipe1() {
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r1;
		newRecipe.setAmtSugar(2);
		assertTrue(cm.editRecipe(r1, newRecipe));
	}
}